/**
 * 登陆
 * @author 康文程
 * @date 2023-12-24 下午 12:30
 */
class Login {
    /**
     * 异步判断账号和密码是否存在
     * @param id 账号
     * @param password 密码
     * @return {Promise<boolean>} true存在 false不存在
     */
    landing(id,password){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/account",
                method: "GET",
                data: {
                    id: id,
                    password:password
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 手机号是否存在
     * @param phone 手机号
     * @return {Promise<unknown>}
     */
    isPhoneEnroll(phone){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/account",
                method: "POST",
                data: {
                    phone: phone
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 邮箱是否已经存在
     * @param mailbox 邮箱
     * @return {Promise<unknown>}
     */
    isMailboxEnroll(mailbox){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/login",
                method: "POST",
                data: {
                    mailbox: mailbox
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }
    /**
     * 手机号账号表新增
     * @param phone 手机号
     * @param password 密码
     * @return {Promise<unknown>} true注册成功 false 注册失败
     */
    phoneRegistration(phone,password){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/phone/registration",
                method: "POST",
                data: {
                    phone: phone,
                    password:password
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 邮箱账号表新增
     * @param mailbox 邮箱
     * @param password 密码
     * @return {Promise<unknown>} true 注册成功 false注册失败
     */
    mailboxRegistration(mailbox,password){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/mailbox/registration",
                method: "POST",
                data: {
                    mailbox: mailbox,
                    password:password
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }
    jumpLogin(menu){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/login",
                method: "GET",
                data: {
                    menu: menu
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

}